/*  Copyright (C) 2008 clement leger
*
*
*  This program is free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; by version 2 of the License.
*
*  This program is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  You should have received a copy of the GNU General Public License
*  along with this program; if not, write to the Free Software
*  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*
*/


#include <bluetooth/sdp.h>
#include <bluetooth/sdp_lib.h>
#include <X11/Xlib.h>

#define KEY_PRESS 1
#define MOVE      2
#define END 	  3
#define NONE	  -1

#define MAX_BUFFER 1024

#define OFFSET     10

#define LEVEL1		7

#define MOVE_CONST 1.5


typedef struct nokchuk_control{
	int offset;
	//invert Y coordinates if 1 no if -1 yes
	int inv;
	//state of button
	int btn1;
	int level1;
}nokchuk_control;


typedef struct nokchuk_action{
	int type;
	char *key;
	int x , y , z;
}nokchuk_action;


typedef struct nokchuk{
	int channel;
	int socket;
	int socket_client;
	char* client_mac;
	sdp_record_t *sdp_record;
	sdp_session_t *sdp_session;
	nokchuk_action *action;
	Display *display;
	nokchuk_control *control;
}nokchuk;


int nokchuk_do_action(nokchuk *session);
int nokchuk_get_action(nokchuk *session);
int nokchuk_get_coord(char* data,nokchuk *session);
char* nokchuk_read(nokchuk *session);
int nokchuk_client_socket(nokchuk *session);
int nokchuk_bluetooth_socket(nokchuk *session);
int nokchuk_describe_service( nokchuk *sn);
nokchuk* nokchuk_init(int channel);
int nokchuk_start(nokchuk *session);
int nokchuk_stop(nokchuk *session);
